<!--
* @author luguoxiang
* @date 2021-09-07
* 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  <slot v-bind="bind"> {{ bind.text }} </slot>
</template>

<script lang="ts" setup>
import { watch } from 'vue';
import { useCountdown, CountdownOptions } from '@/soar';

interface Props extends CountdownOptions {
  value: string | Date | Number;
}

const props = defineProps<Props>();
const emits = defineEmits(['stop']);

const { data: bind } = useCountdown(props);

watch(
  () => bind.value.stopped,
  (v) => {
    if (v) {
      emits('stop');
    }
  },
);
</script>
<script lang="ts">
export default {
  name: 'LgCountdown',
};
</script>
